﻿using System;
using System.Globalization;
using System.Windows.Data;
using StockholmsStad.Runtime.Serialization.DataContract;

namespace StockholmsStad.Windows.UI.Modules.Minister.Converters
{
    public class MinisterTimeBlockToStartEndTimeString : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(string))
                throw new InvalidOperationException("The target must be a string");

            if (value != null)
            {
                var timeBlock = (MinisterTimeBlock)value;

                return string.Format("{0}/{1}", timeBlock.StartTime.ToString("HH:mm"),
                                     timeBlock.EndTime.ToString("HH:mm"));
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
